/*
 *@本文件禁止非前台相关人员进行修改
 *@如有修改请填写修改人，修改时间，与位置方便维护
 *@本JS功能：整体架构JS
 *@本JS作者：孟令超
 *@编写时间：2017年3月14日
 *@修改人：杨锡君	
 *@修改时间：2017年5月8日
 *@修改原因：JS
 *@修改位置或名称：暂无
 */

$(function() {
	var $department = $(".department");
	var $specialty = $(".specialty");
	var $courses = $(".courses");
	var $classPlace = $(".classPlace");
	var $teachers = $(".teachers");
	var $direct = $(".direct");
	//	var $classes = $(".classes");
	var $courseTime = $(".courseTime");
	var $departmentS = $(".departmentS");
	var $specialtyS = $(".specialtyS");
	var $coursesS = $(".coursesS");
	var $classPlaceS = $(".classPlaceS");
	var $teachersS = $(".teachersS");
	var $directS = $(".directS");
	//	var $classesS = $(".classesS");
	var $timeStart = $(".timeStart");
	var $timeEnd = $(".timeEnd");
	var $arringing = $(".arringing");
	var $selectTea = $(".selectTea");
	var $selectStu = $(".selectStu");
	var $selectTeaS = $(".selectTeaS");
	var $selectStuS = $(".selectStuS");
	var $lesson = $(".lesson");
	var $autoArringing = $(".autoArringing");
	var $timeStart = $(".timeStart");
	var $timeEnd = $(".timeEnd");

	//获取上课时间
	var first = result.paramMap.upOneStart + "--" + result.paramMap.upOneEnd;
	var second = result.paramMap.upTwoStart + "--" + result.paramMap.upTwoEnd;
	var third = result.paramMap.downOneStart + "--" + result.paramMap.downOneEnd;
	var fourth = result.paramMap.downTwoStart + "--" + result.paramMap.downTwoEnd;
	var fifth = result.paramMap.bottomOneStart + "--" + result.paramMap.bottomOneEnd;
	var selectMark = 1;
	var selectMarks = 1;
	var Loading1 = new Loading();
	Loading1.init();
	var Alert1 = new Alert();

	var weeklist = result.dateList;
	var weklist = result.dateList;

	//赋值消息
	var noticeList = result.noticeList;
	//消息赋值
	inNoticeList(noticeList);
	//回首页
	$(".crumbs").children("a:first").click(function() {
		window.location.href = 'skipDepartMentMana?jsonStr={"pageNow":1,"pageSize":10}';
	});
	$(".crumbs").children("a:first").css("cursor", "pointer");
	$(".crumbs").children("a").eq(1).css("cursor", "default");
	//	$(".crumbs").children("div:first").css("cursor", "pointer");
	//	$(".crumbs").children("div:first").click(function() {
	//		window.location.href = 'skipDepartMentMana?jsonStr={"pageNow":1,"pageSize":10}';
	//	});
	$(".qsMark").hover(function() {
		$(".black").css("display", "block");
	}, function() {
		$(".black").css("display", "none");
	});
	$arringing.css("display", "none");
	if(result.parameterMap.selectCourseMark == "2") {
		$selectStu.css("display", "none");
		$selectStuS.css("display", "none");
	} else {
		$selectStu.css("display", "block");
		$selectStuS.css("display", "block");
	}
	$(".table_one").css("cursor", "default");
	//院系显现 其他隐藏
	$(".ds").hide();
	$(".ds:first").show();
	$(".dss").hide();
	$(".dss:first").show();
	//	$(".date-selector").hide();
	//	$(".autoArringing").hide();
	//导航切换

	/*自动排课按钮*/
	$("#selfmotion").click(function() {
		//判断cookie是否过期
		overdue();
		showModal();
	})
	/*关闭按钮*/
	$('.close-btn').click(function() {
		//判断cookie是否过期
		overdue();
		closeModal();
	});
	//日期
	//	$(".dateImg").datetimepicker({
	//		lang: "ch",
	//		format: "Y-m-d",
	//		timepicker: false,
	//		yearStart: 2000,
	//		yearEnd: 2100, 
	//		todayButton: false
	//	});
	var opt = {
		preset: 'date', //日期
		theme: 'auto', //皮肤样式
		lang: "zh",
		mode: 'clickpick', //日期选择模式
		dateFormat: 'yy-mm-dd', // 日期格式
		setText: '确定', //确认按钮名称
		cancelText: '取消', //取消按钮名籍我
		dateOrder: 'yymmdd', //面板中日期排列格式
		dayText: '日',
		monthText: '月',
		yearText: '年', //面板中年月日文字
		endYear: 2050 //结束年份
	};

	$timeStart.mobiscroll(opt);
	$timeEnd.mobiscroll(opt);

	//院系获取
	$.each(result.departmentList, function() {
		$department.append($("<option data-departmentid=" + this.departmentId + ">" + this.departmentName + "</option>"));
		$departmentS.append($("<option data-departmentid=" + this.departmentId + ">" + this.departmentName + "</option>"));
	});
	//上课时间获取
	$(".am").append($("<div class=\"mouseDownS\"><div class=\"fl checkbox\" data-timeid=\"1\">" +
		"</div>" +
		"<div class=\"fl label\">" +
		result.paramMap.upOneStart + "-" + result.paramMap.upOneEnd +
		"</div></div>" +
		"<div class=\"mouseDownS\"><div class=\"fl checkbox\" data-timeid=\"2\">" +
		"</div>" +
		"<div class=\"fl label\">" +
		result.paramMap.upTwoStart + "-" + result.paramMap.upTwoEnd +
		"</div></div>" +
		"<div class=\"mouseDownS\"><div class=\"fl checkbox\" data-timeid=\"3\">" +
		"</div>" +
		"<div class=\"fl label\">" +
		result.paramMap.downOneStart + "-" + result.paramMap.downOneEnd +
		"</div></div>" +
		"<div class=\"mouseDownS\"><div class=\"fl checkbox \" data-timeid=\"4\">" +
		"</div>" +
		"<div class=\"fl label\">" +
		result.paramMap.downTwoStart + "-" + result.paramMap.downTwoEnd +
		"</div></div>" +
		"<div class=\"mouseDownS\"><div class=\"fl checkbox\" data-timeid=\"5\">" +
		"</div>" +
		"<div class=\"fl label\">" +
		result.paramMap.bottomOneStart + "-" + result.paramMap.bottomOneEnd +
		"</div></div>"));
	/*复选点击事件*/
	$('.mouseDown').click(function() {
		//判断cookie是否过期
		overdue();
		$(this).children("div:first").toggleClass("checkbox-selected");

	});
	$('.mouseDownS').click(function() {
		//判断cookie是否过期
		overdue();
		$(this).children("div:first").toggleClass("checkbox-selected");

	});
	//院系改变
	//	departChange($department, $specialty, $courses, $classPlace, $direct, $teachers, $classes, $(".ds").eq(1));
	//	departChange($departmentS, $specialtyS, $coursesS, $classPlaceS, $directS, $teachersS, $classesS, $(".dss").eq(1));
	departChange($department, $specialty, $courses, $classPlace, $direct, $teachers, $(".ds").eq(1));
	departChange($departmentS, $specialtyS, $coursesS, $classPlaceS, $directS, $teachersS, $(".dss").eq(1));
	//专业改变
	$specialty.change(function() {
		//判断cookie是否过期
		overdue();
		//		arringing($specialty, $courses, $classPlace, $direct, $teachers, $classes);
		arringing($specialty, $courses, $classPlace, $direct, $teachers);
		$(".ds").show();
	});
	$specialtyS.change(function() {
			//判断cookie是否过期
			overdue();
			//		arringing($specialtyS, $coursesS, $classPlaceS, $directS, $teachersS, $classesS);
			arringing($specialtyS, $coursesS, $classPlaceS, $directS, $teachersS);
			$(".dss").show();
			$coursesS.empty();

			$coursesS.append($("<option  value=\"0\">请选择</option>"));
			
			$.each(result.courseListAll, function() {
				$coursesS.append($("<option data-coursecolor='" + this.courseColer + "' data-courseid=" + this.courseId + ">" + this.courseName + "</option>"));
			});
		});

	function departChange(opt, obj, op, ot, oj, ob, fn) {
		opt.change(function() {
			//判断cookie是否过期
			overdue();
			weeklist = weklist;
			$(".panel").css("display", "none");
			AddSchedule(result.dateList, 0, "table");
			fn.show();
			var jsonStr = opt.children("option:selected").attr("data-departmentid");
			jsonStr = { "departmentId": jsonStr }
			jsonStr = JSON.stringify(jsonStr);
			obj.empty();
			ob.empty();
			oj.empty();
			op.empty();
			ot.empty();
			//			oo.empty();
			$.ajax({
				type: "post",
				url: "getMyProfessionList",
				data: {
					"jsonStr": jsonStr
				},
				async: true,
				success: function(req) {

					//判断cookie是否过期
					overdue();
					req = JSON.parse(req);
					obj.append($("<option value='0'>请选择</option>"));
					ob.append($("<option value='0'>请选择</option>"));
					oj.append($("<option value='0'>请选择</option>"));
					op.append($("<option value='0'>请选择</option>"));
					ot.append($("<option value='0'>请选择</option>"));
					//					oo.append($("<option value='0'>请选择</option>"));
					if(req.professionList.length != 0) {
						$.each(req.professionList, function() {
							obj.append($("<option data-professionid=" + this.professionId + ">" + this.professionName + "</option>"));
						});
					}

				},
				error: function(err) {
					overdue();
					window.location.href = "skipErrorPage";
				}
			});
		});
	}
	//自动排课
	$autoArringing.click(function() {
		//判断cookie是否过期
		overdue();
		var deid = Number($departmentS.children("option:selected").attr("data-departmentid"));
		var spid = Number($specialtyS.children("option:selected").attr("data-professionid"));
		var drid = Number($directS.children("option:selected").attr("data-mainid"));
		var couid = Number($coursesS.children("option:selected").attr("data-courseid"));
		var teid = $teachersS.children("option:selected").attr("data-stuorteaid");
		//		var classid = Number($classesS.children("option:selected").attr("data-classid"));
		var cpid = Number($classPlaceS.children("option:selected").attr("data-siteid"));
		var timeStart = $timeStart.val();
		var timeEnd = $timeEnd.val();
		var arr = [];
		var arr2 = [];
		var firstTime = (new Date(timeStart)).getTime();
		var lastTime = (new Date(timeEnd)).getTime();

		$(".mouseDown").children("div[class*='checkbox-selected']").map(function() {
			arr.push(Number($(this).attr("data-dateid")));
		});
		$(".mouseDownS").children("div[class*='checkbox-selected']").map(function() {
			arr2.push(Number($(this).attr("data-timeid")))
		})

		if(selectMarks == 2) {
			classid = 0;
			if(deid == undefined || $departmentS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将院系信息补充完整";
				Alert1.init();
				Alert1.show();
			} else if(spid == undefined || $specialtyS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将专业信息补充完整";
				Alert1.init();
				Alert1.show();
			} else if(drid == undefined || $directS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将专业方向信息补充完整";
				Alert1.init();
				Alert1.show();
			} else if(couid == undefined || $coursesS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将课程信息补充完整";
				Alert1.init();
				Alert1.show();
			} else if(teid == undefined || $teachersS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将老师信息补充完整";
				Alert1.init();
				Alert1.show();
			} else if(cpid == undefined || $classPlaceS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将上课地点补充完整";
				Alert1.init();
				Alert1.show();
			} else if(timeStart == "") {
				Alert1.content = "请将开始排课时间补充完整";
				Alert1.init();
				Alert1.show();
			} else if(timeEnd == "") {
				Alert1.content = "请将结束排课时间补充完整";
				Alert1.init();
				Alert1.show();
			} else if(arr.length == 0) {
				Alert1.content = "请选择星期";
				Alert1.init();
				Alert1.show();
			} else if(arr2.length == 0) {
				Alert1.content = "请选择上课时间";
				Alert1.init();
				Alert1.show();
			} else if(firstTime > lastTime) {
				Alert1.content = "开始日期不能在结束日期之后";
				Alert1.init();
				Alert1.show();
			} else {
				//判断cookie是否过期
				overdue();
				//				var json = { "selectMark": selectMarks, "mainId": drid, "departmentId": deid, "professionId": spid, "courseId": couid, "stuorteaId": teid, "classId": classid, "siteId": cpid, "classDateStart": timeStart, "classDateEnd": timeEnd, "weekList": arr, "classNumList": arr2 };
				var json = { "selectMark": selectMarks, "mainId": drid, "departmentId": deid, "professionId": spid, "courseId": couid, "stuorteaId": teid, "siteId": cpid, "classDateStart": timeStart, "classDateEnd": timeEnd, "weekList": arr, "classNumList": arr2 };
				jsonStr = JSON.stringify(json);

				confirm1.content = "是否确定自动排课？";
				confirm1.init();
				confirm1.success = function() {
					Loading1.show();
					$.ajax({
						type: "post",
						url: "saveAutoCourseTab",
						async: true,
						data: {
							"jsonStr": jsonStr
						},
						success: function(msg) {

							//判断cookie是否过期
							overdue();
							msg = JSON.parse(msg)
							if(msg.result == "success") {
								Alert1.content = "自动排课成功";
								Alert1.success = function() {
									Loading1.hide();
									window.location.href = "skipManagerCourseTabMana?jsonStr={\"pageNow\":1,\"pageSize\":10}";
								}
								Alert1.init();
								Alert1.show();

							} else {
								if(msg.result != undefined) {
									Alert1.content = msg.failMsg;
									Alert1.success = function() {
										Loading1.hide();
									};

									Alert1.init();
									Alert1.show();
								} else {
									Alert1.content = "排课失败！！";
									Alert1.success = function() {
										Loading1.hide();
									};
									Alert1.init();
									Alert1.show();
								}
							}
						},
						error: function(err) {
							overdue();
							window.location.href = "skipErrorPage";
							Loading1.hide();
						}
					});
				};
				confirm1.show();

			}
		} else {
			if(deid == undefined || $departmentS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将院系信息补充完整";
				Alert1.init();
				Alert1.show();
			} else if(spid == undefined || $specialtyS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将专业信息补充完整";
				Alert1.init();
				Alert1.show();
			} else if(drid == undefined || $directS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将专业方向信息补充完整";
				Alert1.init();
				Alert1.show();
			} else if(couid == undefined || $coursesS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将课程信息补充完整";
				Alert1.init();
				Alert1.show();
			} else if(teid == undefined || $teachersS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将老师信息补充完整";
				Alert1.init();
				Alert1.show();
			}
			//else if(classid == undefined || $classesS.children("option:selected").attr("value") == 0) {
			//				Alert1.content = "请将班级信息补充完整";
			//				Alert1.init();
			//				Alert1.show();
			//			} 
			else if(cpid == undefined || $classPlaceS.children("option:selected").attr("value") == 0) {
				Alert1.content = "请将上课地点补充完整";
				Alert1.init();
				Alert1.show();
			} else if(timeStart == "") {
				Alert1.content = "请将开始排课时间补充完整";
				Alert1.init();
				Alert1.show();
			} else if(timeEnd == "") {
				Alert1.content = "请将结束排课时间补充完整";
				Alert1.init();
				Alert1.show();
			} else if(arr.length == 0) {
				Alert1.content = "请选择星期";
				Alert1.init();
				Alert1.show();
			} else if(arr2.length == 0) {
				Alert1.content = "请选择上课时间";
				Alert1.init();
				Alert1.show();
			} else if(firstTime > lastTime) {
				Alert1.content = "开始日期不能在结束日期之后";
				Alert1.init();
				Alert1.show();
			} else {
				//判断cookie是否过期
				overdue();
				var json = { "selectMark": selectMarks, "mainId": drid, "departmentId": deid, "professionId": spid, "courseId": couid, "stuorteaId": teid, "siteId": cpid, "classDateStart": timeStart, "classDateEnd": timeEnd, "weekList": arr, "classNumList": arr2 };

				jsonStr = JSON.stringify(json);

				confirm1.content = "是否确定自动排课？";
				confirm1.init();
				confirm1.success = function() {
					Loading1.show();
					$.ajax({
						type: "post",
						url: "saveAutoCourseTab",
						async: true,
						data: {
							"jsonStr": jsonStr
						},
						success: function(msg) {;
							//判断cookie是否过期
							overdue();
							msg = JSON.parse(msg)
							if(msg.result == "success") {
								Alert1.content = "自动排课成功";
								Alert1.success = function() {

									window.location.href = "skipManagerCourseTabMana?jsonStr={\"pageNow\":1,\"pageSize\":10}";
									Loading1.hide()
								}
								Alert1.init();
								Alert1.show();

							} else {
								if(msg.result != undefined) {
									Alert1.content = msg.failMsg;
									Alert1.success = function() {
										Loading1.hide();
									};
									Alert1.init();
									Alert1.show();
								} else {
									Alert1.content = "排课失败！！";
									Alert1.success = function() {
										Loading1.hide();
									};
									Alert1.init();
									Alert1.show();
								}
							}
						},
						error: function(err) {
							window.location.href = "skipErrorPage";
							Loading1.hide();
						}
					});
				};
				confirm1.show();

			}
		}

	});
	$(".panel").css("display", "none");
	AddSchedule(result.dateList, 0, "table");

	//	*
	// *创建添加课表方法
	// *参数：result 课程数组
	// *     boxId  课程表外层盒子ID
	// *调用方法： AddSchedule(result,"aaaa");

	function AddSchedule(weekData, result, boxId) {
		$("#" + boxId).empty();
		$("#" + boxId).append('<tr></tr>');
		$("#" + boxId + " tr").eq(0).append('<th class="first-td"></th>');
		$("#" + boxId).append('<tr></tr>');
		$("#" + boxId + " tr").eq(1).append('<th class="first-td workt">上午</th>');
		$("#" + boxId).append('<tr></tr>');
		$("#" + boxId + " tr").eq(2).append('<th class="first-td workt">下午</th>');
		$("#" + boxId).append('<tr></tr>');
		$("#" + boxId + " tr").eq(3).append('<th class="first-td workt2">晚课</th>');

		for(var k = 0; k < weekData.length; k++) {
			var ar = weekData[k].split(" ");
			$("#" + boxId + " tr").eq(0).append('<th>' +
				'<div class="week2"><span class=\'weekD\'>' + ar[1] + '</span><span class="weekE">' + ar[0] + '</span></div>' +
				'</th>');
			$("#" + boxId + " tr").eq(1).append('<td data-value=' + k + '><div class="class-panel td_top" data-num="1" data-classnum=' + first + '></div><div class="class-panel td_bottom"  data-num="2" data-classnum=' + second + '></td>');
			$("#" + boxId + " tr").eq(2).append('<td data-value=' + k + '><div  data-num="3" class="class-panel td_top" data-classnum=' + third + '></div><div class="class-panel td_bottom"  data-num="4" data-classnum=' + fourth + '></td>');
			$("#" + boxId + " tr").eq(3).append('<td data-value=' + k + '><div class="class-panel td_top"  data-num="5" data-classnum=' + fifth + '></td>');
		}
		if(result != 0) {
			for(var i = 0; i < result.length; i++) {
				//		/*判断星期*/
				var week = "";
				var place_row = "";
				var place_list = "";
				if(result[i].classDate == weekData[0].split(" ")[0]) {
					week = 0;
				} else if(result[i].classDate == weekData[1].split(" ")[0]) {
					week = 1;
				} else if(result[i].classDate == weekData[2].split(" ")[0]) {
					week = 2;
				} else if(result[i].classDate == weekData[3].split(" ")[0]) {
					week = 3;
				} else if(result[i].classDate == weekData[4].split(" ")[0]) {
					week = 4;
				} else if(result[i].classDate == weekData[5].split(" ")[0]) {
					week = 5;
				} else if(result[i].classDate == weekData[6].split(" ")[0]) {
					week = 6;
				}
				/*判断当前位置*/
				if(result[i].classNum == "1") {
					var place_row = 1;
					var place_list = 0;
				} else if(result[i].classNum == "2") {
					var place_row = 1;
					var place_list = 1;
				} else if(result[i].classNum == "3") {
					var place_row = 2;
					var place_list = 0;
				} else if(result[i].classNum == "4") {
					var place_row = 2;
					var place_list = 1;
				} else if(result[i].classNum == "5") {
					var place_row = 3;
					var place_list = 0;
				}
				var colorArr = getColor(result[i].courseColer);
				$("#" + boxId + " tr").eq(place_row).find("td").eq(week).children("div").eq(place_list).addClass(colorArr[0]);
				$("#" + boxId + " tr").eq(place_row).find("td").eq(week).children("div").eq(place_list).append('<div>课程名称：' + result[i].courseName + '</div><div>上课地点：' + result[i].siteName + '</div><div>上课时间：' + result[i].startTime + '-' + result[i].endTime + '</div>');
			}

		}

	}

	var confirm1 = new Confirm();
	// 绑定课表翻页按钮

	$(".week-btn").click(function() {
		//判断cookie是否过期
		overdue();
		//		$classPlace.val("0");
		var offset = $(this).attr("offset");
		if($arringing.attr("style") == "display: block;") {
			//判断cookie是否过期
			overdue();
			confirm1.content = "未保存，是否确定翻页？";
			confirm1.init();
			confirm1.success = function() {
				$arringing.css("display", "none");
				if(offset == "1") {
					var week = weeklist[weeklist.length - 1].split(" ");
					var newdata = QueryDate(week[0], 2); // 返回的上周六日期
				} else if(offset == "-1") {
					var week = weeklist[0].split(" ");
					var newdata = QueryDate(week[0], 1); // 返回的下周一日期
				}
				var jsonStr;
				if($classPlace.children("option:selected").attr("value") == 0) {
					jsonStr = { "nowDate": newdata };
				} else {
					jsonStr = { "nowDate": newdata, "siteId": $classPlace.children("option:selected").attr("data-siteid") };
				}
				jsonStr = JSON.stringify(jsonStr);

				$.ajax({
					url: 'getLastAndAfterTab', // 跳转到 action    
					data: {
						'jsonStr': jsonStr
					},
					type: 'post',
					cache: false,
					dataType: 'json',
					success: function(data) {

						//判断cookie是否过期
						overdue();
						weeklist = data.dateList;
						AddSchedule(data.dateList, 0, "table");
						site();

					},
					error: function() {
						window.location.href = "skipErrorPage";
						//alert("异常！");    
					}
				});
			};
			confirm1.show();
		} else {
			//判断cookie是否过期
			overdue();
			$arringing.css("display", "none");
			if(offset == "1") {
				var week = weeklist[weeklist.length - 1].split(" ");
				var newdata = QueryDate(week[0], 2); // 返回的上周六日期
			} else if(offset == "-1") {
				var week = weeklist[0].split(" ");
				var newdata = QueryDate(week[0], 1); // 返回的下周一日期
			}
			var jsonStr = { "nowDate": newdata };
			jsonStr = JSON.stringify(jsonStr);

			$.ajax({
				url: 'getLastAndAfterTab', // 跳转到 action    
				data: {
					'jsonStr': jsonStr
				},
				type: 'post',
				cache: false,
				dataType: 'json',
				success: function(data) {

					//判断cookie是否过期
					overdue();
					weeklist = data.dateList;
					AddSchedule(data.dateList, 0, "table");
					site();

				},
				error: function() {
					window.location.href = "skipErrorPage";
					//alert("异常！");  

				}
			});
		}

	});
	//点击课表
	//	table_click();
	function table_click() {

		$(".class-panel").click(function() {

			if(selectMark == 1) {
				//判断cookie是否过期
				overdue();
				if($department.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将院系信息补充完整";
					Alert1.init();
					Alert1.show();
				} else if($specialty.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将专业信息补充完整";
					Alert1.init();
					Alert1.show();
				} else if($direct.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将专业方向信息补充完整";
					Alert1.init();
					Alert1.show();
				}
				//				else if($classes.children("option:selected").attr("value") == 0) {
				//					Alert1.content = "如需排课，请将班级信息补充完整";
				//					Alert1.init();
				//					Alert1.show();
				//				} 
				else if($courses.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将课程信息补充完整";
					Alert1.init();
					Alert1.show();
				} else if($teachers.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将老师信息补充完整";
					Alert1.init();
					Alert1.show();
				} else if($classPlace.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将上课地点信息补充完整";
					Alert1.init();
					Alert1.show();
				} else {

					var colorid = $courses.children("option:selected").attr("data-coursecolor");
					var arr = getColor(colorid);
					if($(this).attr("data-alert") == 0) {
						var n = 0;
					} else {

						if($(this).children("p").length != 0) {
							$(this).empty();

							if($courses.children("option:selected").attr("data-courseid") != $(this).attr("data-courseid")) {
								$(this).attr("class", "class-panel td_top");
								$(this).addClass(arr[0]);
								$(this).attr("data-courseid", $courses.children("option:selected").attr("data-courseid"));
								$(this).append("<p data-date=\"" + $(".week2").eq($(this).parent("td").attr("data-value")).children("span").eq(1).html() + "\"  data-departmentid=\"" + $department.children("option:selected").attr("data-departmentid") + "\"  data-professionid=\"" + $specialty.children("option:selected").attr("data-professionid") + "\"  data-courseid=\"" + $courses.children("option:selected").attr("data-courseid") + "\"  data-stuorteaid=\"" + $teachers.children("option:selected").attr("data-stuorteaid") + "\" data-classid=\"\"  data-siteid=\"" + $classPlace.children("option:selected").attr("data-siteid") + "\" title=" + $courses.children("option:checked").html() + ">" + $courses.children("option:checked").html() + "</p><p>" + $(this).attr("data-classnum") + "</p>");
							} else {
								$(this).attr("value", "");
								$(this).attr("class", "class-panel td_top");
								$(this).attr("data-courseid", $courses.children("option:selected").attr("data-courseid"));

							}
							$arringing.css("display", "block");
							if($("div[value=0]").length == 0) {
								$arringing.css("display", "none");
							}
						} else {
							$arringing.css("display", "block");
							$(this).attr("value", 0);
							$(this).attr("class", "class-panel td_top");
							$(this).addClass(arr[0]);
							$(this).attr("data-courseid", $courses.children("option:selected").attr("data-courseid"));
							$(this).append("<p data-date=\"" + $(".week2").eq($(this).parent("td").attr("data-value")).children("span").eq(1).html() + "\"  data-departmentid=\"" + $department.children("option:selected").attr("data-departmentid") + "\"  data-professionid=\"" + $specialty.children("option:selected").attr("data-professionid") + "\"  data-courseid=\"" + $courses.children("option:selected").attr("data-courseid") + "\"  data-stuorteaid=\"" + $teachers.children("option:selected").attr("data-stuorteaid") + "\" data-classid=\"\"  data-siteid=\"" + $classPlace.children("option:selected").attr("data-siteid") + "\" title=" + $courses.children("option:checked").html() + ">" + $courses.children("option:checked").html() + "</p><p>" + $(this).attr("data-classnum") + "</p>");
						}

					}

				}
			} else {
				//判断cookie是否过期
				overdue();
				if($department.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将院系信息补充完整";
					Alert1.init();
					Alert1.show();
				} else if($specialty.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将专业信息补充完整";
					Alert1.init();
					Alert1.show();
				} else if($direct.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将专业方向信息补充完整";
					Alert1.init();
					Alert1.show();
				} else if($courses.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将课程信息补充完整";
					Alert1.init();
					Alert1.show();
				} else if($teachers.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将老师信息补充完整";
					Alert1.init();
					Alert1.show();
				} else if($classPlace.children("option:selected").attr("value") == 0) {
					Alert1.content = "如需排课，请将上课地点信息补充完整";
					Alert1.init();
					Alert1.show();
				} else {

					var colorid = $courses.children("option:selected").attr("data-coursecolor");
					var arr = getColor(colorid);
					if($(this).attr("data-alert") == 0) {
						var n = 0;
					} else {

						if($(this).children("p").length != 0) {
							$(this).empty();
							$(this).attr("value", "");
							$(this).removeClass(arr[0]);
							$arringing.css("display", "block");
							if($("div[value=0]").length == 0) {
								$arringing.css("display", "none");
							}
						} else {
							$arringing.css("display", "block");
							$(this).attr("value", 0);
							$(this).addClass(arr[0]);
							$(this).append("<p data-date=\"" + $(".week2").eq($(this).parent("td").attr("data-value")).children("span").eq(1).html() + "\"  data-departmentid=\"" + $department.children("option:selected").attr("data-departmentid") + "\"  data-professionid=\"" + $specialty.children("option:selected").attr("data-professionid") + "\"  data-courseid=\"" + $courses.children("option:selected").attr("data-courseid") + "\"  data-stuorteaid=\"" + $teachers.children("option:selected").attr("data-stuorteaid") + "\" data-classid=\"0\"  data-siteid=\"" + $classPlace.children("option:selected").attr("data-siteid") + "\">" + $courses.children("option:checked").html() + "</p><p>" + $(this).attr("data-classnum") + "</p>");
						}

					}

				}
			}

		});
	}
	//获取查询日期的 上周下载日期
	function QueryDate(newDate, newType) {
		var sss = newDate;
		var str = sss.replace(/-/g, "/");
		var date = new Date(str);
		//将年月日进行格式化，yyyy-MM-dd
		Date.prototype.Format = function(fmt) { //author: meizz
			var o = {
				"M+": this.getMonth() + 1, //月份 
				"d+": this.getDate(), //日 
				"h+": this.getHours(), //小时 
				"m+": this.getMinutes(), //分 
				"s+": this.getSeconds(), //秒 
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度 
				"S": this.getMilliseconds() //毫秒 
			};
			if(/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
			for(var k in o)
				if(new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
			return fmt;
		};

		//得到sss声明的变量的日期的前两天 
		if(newType == "1") {
			return new Date(date - 48 * 60 * 60 * 1000).Format("yyyy-MM-dd");
		} else if(newType == "2") { // 获取下周一日期
			return new Date(date.getTime() + 24 * 60 * 60 * 1000).Format("yyyy-MM-dd");
		}

	}

	//上课地点改变
	$classPlace.change(function() {
		//判断cookie是否过期
		overdue();
		site();
	});
	//	$classPlaceS.change(function() {
	//		$(".date-selector").show();
	//		$(".autoArringing").show();
	//	});

	function site() {
		$(".panel").css("display", "block");
		var Ndate = $(".week2").eq(0).children("span").eq(1).html();
		var siteId = Number($classPlace.children("option:selected").attr("data-siteid"));
		var jsonStr = { "nowDate": Ndate, "siteId": siteId };
		jsonStr = JSON.stringify(jsonStr);
		//判断cookie是否过期
		overdue();
		if($classPlace.children("option:selected").attr("value") != 0) {
			$.ajax({
				type: "post",
				url: "getLastAndAfterTab",
				data: {
					"jsonStr": jsonStr
				},
				async: true,
				success: function(msg) {
					//判断cookie是否过期
					overdue();

					msg = JSON.parse(msg);
					AddSchedule(msg.dateList, 0, "table");
					$.map(msg.classTab, function(opt) {
						var arr = getColor(opt.courseColer);
						if(opt.week == "星期一") {
							$("td[data-value='0']").children("div[data-num='" + opt.classNum + "']").empty().append($("<div title=" + opt.courseName + ">" + opt.courseName + "</div><div>" + opt.startTime + "--" + opt.endTime + "</div>"));
							$("td[data-value='0']").children("div[data-num='" + opt.classNum + "']").attr("data-alert", "0");
							$("td[data-value='0']").children("div[data-num='" + opt.classNum + "']").addClass(arr[0]);
						} else if(opt.week == "星期二") {
							$("td[data-value='1']").children("div[data-num='" + opt.classNum + "']").empty().append($("<div title=" + opt.courseName + ">" + opt.courseName + "</div><div>" + opt.startTime + "--" + opt.endTime + "</div>"));
							$("td[data-value='1']").children("div[data-num='" + opt.classNum + "']").attr("data-alert", "0");
							$("td[data-value='1']").children("div[data-num='" + opt.classNum + "']").addClass(arr[0]);
						} else if(opt.week == "星期三") {
							$("td[data-value='2']").children("div[data-num='" + opt.classNum + "']").empty().append($("<div title=" + opt.courseName + ">" + opt.courseName + "</div><div>" + opt.startTime + "--" + opt.endTime + "</div>"));
							$("td[data-value='2']").children("div[data-num='" + opt.classNum + "']").attr("data-alert", "0");
							$("td[data-value='2']").children("div[data-num='" + opt.classNum + "']").addClass(arr[0]);
						} else if(opt.week == "星期四") {
							$("td[data-value='3']").children("div[data-num='" + opt.classNum + "']").empty().append($("<div title=" + opt.courseName + ">" + opt.courseName + "</div><div>" + opt.startTime + "--" + opt.endTime + "</div>"));
							$("td[data-value='3']").children("div[data-num='" + opt.classNum + "']").attr("data-alert", "0");
							$("td[data-value='3']").children("div[data-num='" + opt.classNum + "']").addClass(arr[0]);
						} else if(opt.week == "星期五") {
							$("td[data-value='4']").children("div[data-num='" + opt.classNum + "']").empty().append($("<div title=" + opt.courseName + ">" + opt.courseName + "</div><div>" + opt.startTime + "--" + opt.endTime + "</div>"));
							$("td[data-value='4']").children("div[data-num='" + opt.classNum + "']").attr("data-alert", "0");
							$("td[data-value='4']").children("div[data-num='" + opt.classNum + "']").addClass(arr[0]);
						} else if(opt.week == "星期六") {
							$("td[data-value='5']").children("div[data-num='" + opt.classNum + "']").empty().append($("<div title=" + opt.courseName + ">" + opt.courseName + "</div><div>" + opt.startTime + "--" + opt.endTime + "</div>"));
							$("td[data-value='5']").children("div[data-num='" + opt.classNum + "']").attr("data-alert", "0");
							$("td[data-value='5']").children("div[data-num='" + opt.classNum + "']").addClass(arr[0]);
						} else {
							$("td[data-value='6']").children("div[data-num='" + opt.classNum + "']").empty().append($("<div title=" + opt.courseName + ">" + opt.courseName + "</div><div>" + opt.startTime + "--" + opt.endTime + "</div>"));
							$("td[data-value='6']").children("div[data-num='" + opt.classNum + "']").attr("data-alert", "0");
							$("td[data-value='6']").children("div[data-num='" + opt.classNum + "']").addClass(arr[0]);
						}

					});

					table_click();
				},
				error: function() {
					window.location.href = "skipErrorPage";
				}
			});
		}

	}


	//教师or学生
	$selectTea.click(function() {
		//判断cookie是否过期
		overdue();
		$teachers.off("change").change(function() {

			if($teachers.val() != 0) {
				var jsonStr = JSON.stringify({ "stuorteaId": $teachers.children("option:selected").attr("data-stuorteaid") });
				$.ajax({
					type: "post",
					url: "getMyClasses",
					async: true,
					data: {
						"jsonStr": jsonStr
					},
					success: function(msg) {
						msg = JSON.parse(msg);

						$courses.empty();
						$courses.append("<option  value=\"0\">请选择</option>");

						$.each(msg.courseList, function() {
							$courses.append($("<option data-coursecolor='" + this.courseColer + "' data-courseid=" + this.courseId + ">" + this.courseName + "</option>"));
						});

					}
				});
			}
		});
		if($arringing.attr("style") == "display: block;") {
			var confirm1 = new Confirm();
			confirm1.content = "未保存，是否确定翻页？";
			confirm1.init();
			confirm1.success = function() {
				$(".apply").css("display", "");
				$(".ds").hide();
				$(".ds:first").show();
				$department.val("0");
				$(".panel").css("display", "none");
				selectMark = 1;
				$selectTea.removeClass("option_Noselect");
				$selectTea.addClass("option_select");
				$selectStu.addClass("option_Noselect");
				$selectStu.removeClass("option_select");
				AddSchedule(result.dateList, 0, "table");
				$arringing.css("display", "none");
			}
			confirm1.show();
		} else {
			//判断cookie是否过期
			overdue();
			$(".apply").css("display", "");
			$(".ds").hide();
			$(".ds:first").show();
			$department.val("0");
			$(".panel").css("display", "none");
			selectMark = 1;
			$selectTea.addClass("option_select");
			$selectStu.addClass("option_Noselect");
			$selectStu.removeClass("option_select");
			$selectTea.removeClass("option_Noselect");
			AddSchedule(result.dateList, 0, "table");
			$arringing.css("display", "none");
		}

	});
	$selectStu.click(function() {
		//判断cookie是否过期
		overdue();
		//教师改变
		$teachers.off("change");
		if($arringing.attr("style") == "display: block;") {

			var confirm1 = new Confirm();
			confirm1.content = "未保存，是否确定翻页？";
			confirm1.init();
			confirm1.success = function() {
				//				$(".apply").hide();
				$(".ds").hide();
				$(".ds:first").show();
				$department.val("0");
				$arringing.css("display", "none");
				selectMark = 2;
				$selectStu.addClass("option_select");
				$selectTea.addClass("option_Noselect");
				$selectTea.removeClass("option_select");
				$selectStu.removeClass("option_Noselect");
				$(".panel").css("display", "none");
				AddSchedule(result.dateList, 0, "table");
				
			}
			confirm1.show();
		} else {
			//判断cookie是否过期
			overdue();
			//			$(".apply").hide();
			$(".ds").hide();
			$(".ds:first").show();
			$department.val("0");
			$arringing.css("display", "none");
			selectMark = 2;
			$selectStu.addClass("option_select");
			$selectTea.addClass("option_Noselect");
			$selectTea.removeClass("option_select");
			$selectStu.removeClass("option_Noselect");
			$(".panel").css("display", "none");
			AddSchedule(result.dateList, 0, "table");
			
		}

	});
	$selectTeaS.click(function() {
		//判断cookie是否过期
		overdue();
		$teachersS.off("change").change(function() {
			if($teachersS.val() != 0) {
				var jsonStr = JSON.stringify({ "stuorteaId": $teachersS.children("option:selected").attr("data-stuorteaid") });
				$.ajax({
					type: "post",
					url: "getMyClasses",
					async: true,
					data: {
						"jsonStr": jsonStr
					},
					success: function(msg) {
						msg = JSON.parse(msg);

						$coursesS.empty();
						$coursesS.append("<option  value=\"0\">请选择</option>");

						$.each(msg.courseList, function() {
							$coursesS.append($("<option data-coursecolor='" + this.courseColer + "' data-courseid=" + this.courseId + ">" + this.courseName + "</option>"));
						});

					}
				});
			}
		});
		//		$(".applys").hide();
		$(".dss").hide();
		$(".dss:first").show();
		//		$departmentS.val("0");
		$(this).addClass("option_select");
		$selectStuS.addClass("option_Noselect");
		$selectStuS.removeClass("option_select");
		$(this).removeClass("option_Noselect");
		selectMarks = 1;
		//		$(".applys").css("display", "block");
		$departmentS.val("0");
		$specialtyS.val("0");
		$directS.val("0");
		$coursesS.val("0");
		$teachersS.val("0");
		//		$classesS.val("0");
		$classPlaceS.val("0");
		$timeStart.val("");
		$timeEnd.val("");
		$(".mouseDown").children("div:first").attr("class", "fl checkbox");
		$(".mouseDownS").children("div:first").attr("class", "fl checkbox");
	});
	$selectStuS.click(function() {
		//判断cookie是否过期
		overdue();
		//教师改变
		$teachersS.off("change");
		
		//		$(".applys").hide();
		$(".dss").hide();
		$(".dss:first").show();
		
		$(this).addClass("option_select");
		$selectTeaS.addClass("option_Noselect");
		$selectTeaS.removeClass("option_select");
		$(this).removeClass("option_Noselect");
		selectMarks = 2;
		//		$(".applys").css("display", "none");
		$departmentS.val("0");
		$specialtyS.val("0");
		$directS.val("0");
		$coursesS.val("0");
		$teachersS.val("0");
		//		$classesS.val("0");
		$classPlaceS.val("0");
		$timeStart.val("");
		$timeEnd.val("");
		$(".mouseDown").children("div:first").attr("class", "fl checkbox");
		$(".mouseDownS").children("div:first").attr("class", "fl checkbox");
	});
	//保存
	$arringing.click(function() {
		//判断cookie是否过期
		overdue();
		Loading1.show();
		var deid = Number($department.children("option:selected").attr("data-departmentid"));
		var spid = Number($specialty.children("option:selected").attr("data-professionid"));
		var couid = Number($courses.children("option:selected").attr("data-courseid"));
		var teid = $teachers.children("option:selected").attr("data-stuorteaid");
		//		var classid = Number($classes.children("option:selected").attr("data-classid"));
		var cpid = Number($classPlace.children("option:selected").attr("data-siteid"));
		var drid = Number($direct.children("option:selected").attr("data-mainid"));
		//		if($classes.attr("style") == "display: none;") {
		//			classid = 0;
		//		}
		var json = {};
		var arr = [];
		$.each($(".class-panel[value=0]"), function(key) {
			//			json = { "selectMark": selectMark, "mainId": drid, "departmentId": Number($(this).children("p:first").attr("data-departmentid")), "professionId": Number($(this).children("p:first").attr("data-professionid")), "courseId": Number($(this).children("p:first").attr("data-courseid")), "stuorteaId": $(this).children("p:first").attr("data-stuorteaid"), "classId": Number($(this).children("p:first").attr("data-classid")), "siteId": Number($(this).children("p:first").attr("data-siteid")), "classNum": Number($(this).attr("data-num")), "classDate": $(this).children("p:first").attr("data-date") };
			json = { "selectMark": selectMark, "mainId": drid, "departmentId": Number($(this).children("p:first").attr("data-departmentid")), "professionId": Number($(this).children("p:first").attr("data-professionid")), "courseId": Number($(this).children("p:first").attr("data-courseid")), "stuorteaId": $(this).children("p:first").attr("data-stuorteaid"), "siteId": Number($(this).children("p:first").attr("data-siteid")), "classNum": Number($(this).attr("data-num")), "classDate": $(this).children("p:first").attr("data-date") };
			arr.push(json);
		});
		var jsonStr = { "tabList": arr };
		jsonStr = JSON.stringify(jsonStr);
		
		$.ajax({
			type: "post",
			url: "saveCourseTab",
			async: true,
			data: {
				"jsonStr": jsonStr
			},
			success: function(msg) {
				//判断cookie是否过期
				overdue();
				Loading1.hide();
				msg = JSON.parse(msg)
				if(msg.result == "success") {
					Alert1.content = "排课成功";
					Alert1.success = function() {

						window.location.href = "skipManagerCourseTabMana?jsonStr={\"pageNow\":1,\"pageSize\":10}";
					};
					Alert1.init();
					Alert1.show();

				} else {
					if(msg.result != undefined) {
						Alert1.content = msg.failMsg;

						//判断cookie是否过期
						overdue();
						$arringing.css("display", "none");
						//							$classPlace.val("0");
						//							AddSchedule(result.dateList, 0, "table");
						//							weeklist = weklist ;

						table_click();
						site();
						table_click();

						Alert1.init();
						Alert1.show();
					} else {
						Alert1.content = "排课失败！！";

						//判断cookie是否过期
						overdue();
						$arringing.css("display", "none");
						//							$classPlace.val("0");
						//							AddSchedule(result.dateList, 0, "table");
						//							weeklist = weklist ;
						table_click();
						site();
						table_click();
						Alert1.init();
						Alert1.show();
						//							AddSchedule(result.dateList, 0, "table");
						//							table_click();
					}
				}
			},
			error: function(err) {
				window.location.href = "skipErrorPage";
				Loading1.hide();
			}
		});

	});
	//本周
	$(".nowDay_btn").click(function() {
		//判断cookie是否过期
		overdue();

		if($arringing.attr("style") == "display: block;") {
			var confirm1 = new Confirm();
			confirm1.content = "未保存，是否确定翻页？";
			confirm1.init();
			confirm1.success = function() {

				$arringing.css("display", "none");
				var myDate = new Date();
				var now = myDate.toLocaleDateString();
				now = now.replace(/\//gi, "-");
				var jsonStr;
				if($classPlace.children("option:selected").attr("value") == 0) {
					jsonStr = { "nowDate": now };
				} else {
					jsonStr = { "nowDate": now, "siteId": $classPlace.children("option:selected").attr("data-siteid") };
				}
				jsonStr = JSON.stringify(jsonStr);
				$.ajax({
					url: 'getLastAndAfterTab', // 跳转到 action    
					data: {
						'jsonStr': jsonStr
					},
					type: 'post',
					cache: false,
					dataType: 'json',
					success: function(data) {

						//判断cookie是否过期
						overdue();
						weeklist = data.dateList;
						AddSchedule(data.dateList, 0, "table");
						site();

					},
					error: function() {
						window.location.href = "skipErrorPage";
						//alert("异常！");    
					}
				});
			};
			confirm1.show();
		} else {
			//判断cookie是否过期
			overdue();

			$arringing.css("display", "none");
			var myDate = new Date();
			var now = myDate.toLocaleDateString();
			now = now.replace(/\//gi, "-");
			var jsonStr;
			if($classPlace.children("option:selected").attr("value") == 0) {
				jsonStr = { "nowDate": now };
			} else {
				jsonStr = { "nowDate": now, "siteId": $classPlace.children("option:selected").attr("data-siteid") };
			}
			jsonStr = JSON.stringify(jsonStr);
			$.ajax({
				url: 'getLastAndAfterTab', // 跳转到 action    
				data: {
					'jsonStr': jsonStr
				},
				type: 'post',
				cache: false,
				dataType: 'json',
				success: function(data) {

					//判断cookie是否过期
					overdue();
					weeklist = data.dateList;
					AddSchedule(data.dateList, 0, "table");
					site();

				},
				error: function() {
					window.location.href = "skipErrorPage";
					//alert("异常！");  

				}
			});
		}

	});
	$(".table_one").click(function() {
		//判断cookie是否过期
		overdue();
		$(".table_one").css("cursor", "default");
		$(".table_two").css("cursor", "");
		$("#main").css("display", "block");
		$(".ds").hide();
		$(".ds:first").show();
		$(".dss").hide();
		$(".dss:first").show();
		$departmentS.val("0");
		$specialtyS.empty();
		$specialtyS.append($("<option  value=\"0\">请选择</option>"));
		$coursesS.empty();
		$coursesS.append($("<option  value=\"0\">请选择</option>"));
		$teachersS.empty();
		$teachersS.append($("<option  value=\"0\">请选择</option>"));
		$classPlaceS.empty();
		$classPlaceS.append($("<option  value=\"0\">请选择</option>"));
		$directS.empty();
		$directS.append($("<option  value=\"0\">请选择</option>"));
		$selectTeaS.removeClass("option_Noselect");
		$selectTeaS.addClass("option_select");
		$selectStuS.removeClass("option_select");
		$selectStuS.addClass("option_Noselect");
		selectMark = 1;
		$(".mouseDown").children("div:first").attr("class", "fl checkbox");
		$(".mouseDownS").children("div:first").attr("class", "fl checkbox");
		$(".table_two").addClass("title_box_select2");
		$(".table_one").addClass("title_box_select");
		$(".table_two").removeClass("title_box_select");
		$(".table_one").removeClass("title_box_select2");
		$('.modal').css("display", "none");

		//		closeModal();

	});

	$(".table_two").click(function() {
		//判断cookie是否过期
		overdue();
		$(".table_one").css("cursor", "");
		$(".table_two").css("cursor", "default");
		$timeStart.val("");
		$timeEnd.val("");
		$department.val("0");
		//		$classes.empty();
		$specialty.empty();
		$classPlace.empty();
		$teachers.empty();
		$direct.empty();
		$courses.empty();
		//		$classes.append($("<option value='0'>请选择</option>"));
		$specialty.append($("<option value='0'>请选择</option>"));
		$classPlace.append($("<option value='0'>请选择</option>"));
		$teachers.append($("<option value='0'>请选择</option>"));
		$direct.append($("<option value='0'>请选择</option>"));
		$courses.append($("<option value='0'>请选择</option>"));
		$selectTea.removeClass("option_Noselect");
		$selectTea.addClass("option_select");
		$selectStu.removeClass("option_select");
		$selectStu.addClass("option_Noselect");
		selectMarks = 1;
		$(".panel").css("display", "none");
		AddSchedule(result.dateList, 0, "table");
		$("#main").css("display", "none");
		//		showModal();
		$(".table_one").removeClass("title_box_select");
		$(".table_two").removeClass("title_box_select2");
		$(".table_one").addClass("title_box_select2");
		$(".table_two").addClass("title_box_select")
		$('.modal').css("display", "block");
	});
	
//	专业联动
		function arringing(opt, op, ot, obj, ob) {

		var jsonStr = opt.children("option:selected").attr("data-professionid");
		jsonStr = { "professionId": jsonStr }
		jsonStr = JSON.stringify(jsonStr);
		//判断cookie是否过期
		overdue();

		$.ajax({
			type: "post",
			url: "getMyProCourseList",
			data: {
				"jsonStr": jsonStr
			},
			async: true,
			success: function(req) {

				//判断cookie是否过期
				overdue();
				req = JSON.parse(req);
				if(selectMark == 2) {
					$(".apply").css("display", "none");
				}
				if(selectMarks == 2) {
					$(".applys").css("display", "none");
				}
				
//					op.empty();
//
//					op.append($("<option  value=\"0\">请选择</option>"));
				
				
				ot.empty();
				obj.empty();
				ob.empty();
				//				oj.empty();

				ot.append($("<option  value=\"0\">请选择</option>"));
				obj.append($("<option  value=\"0\">请选择</option>"));
				ob.append($("<option  value=\"0\">请选择</option>"));
				//				oj.append($("<option  value=\"0\">请选择</option>"));
				if(selectMark == 2) {
					op.empty();

					op.append($("<option  value=\"0\">请选择</option>"));
					if(result.courseListAll.length != 0) {
						$.each(result.courseListAll, function() {
							op.append($("<option data-coursecolor='" + this.courseColer + "' data-courseid=" + this.courseId + ">" + this.courseName + "</option>"));
						});
					}
				} else {
					$teachers.off("change").change(function() {

						if($teachers.val() != 0) {
							var jsonStr = JSON.stringify({ "stuorteaId": $teachers.children("option:selected").attr("data-stuorteaid") });
							$.ajax({
								type: "post",
								url: "getMyClasses",
								async: true,
								data: {
									"jsonStr": jsonStr
								},
								success: function(msg) {
									msg = JSON.parse(msg);

									$courses.empty();
									$courses.append("<option  value=\"0\">请选择</option>");

									$.each(msg.courseList, function() {
										$courses.append($("<option data-coursecolor='" + this.courseColer + "' data-courseid=" + this.courseId + ">" + this.courseName + "</option>"));
									});

								}
							});
						}
					});
				}
				
					
					
				if(selectMarks != 2) {
					$teachersS.off("change").change(function() {
						if($teachersS.val() != 0) {
							var jsonStr = JSON.stringify({ "stuorteaId": $teachersS.children("option:selected").attr("data-stuorteaid") });
							$.ajax({
								type: "post",
								url: "getMyClasses",
								async: true,
								data: {
									"jsonStr": jsonStr
								},
								success: function(msg) {
									msg = JSON.parse(msg);

									$coursesS.empty();
									$coursesS.append("<option  value=\"0\">请选择</option>");

									$.each(msg.courseList, function() {
										$coursesS.append($("<option data-coursecolor='" + this.courseColer + "' data-courseid=" + this.courseId + ">" + this.courseName + "</option>"));
									});

								}
							});
						}
					});
				}
				
				if($(".selectTeaS[class*='option_select']").length != 0){
					
					$coursesS.empty();

					$coursesS.append($("<option  value=\"0\">请选择</option>"));
				}else{
				
					if(result.courseListAll.length != 0) {
						op.empty();

						op.append($("<option  value=\"0\">请选择</option>"));
						$.each(result.courseListAll, function() {
							$coursesS.append($("<option data-coursecolor='" + this.courseColer + "' data-courseid=" + this.courseId + ">" + this.courseName + "</option>"));
						});
					}
				}
				if($(".selectTea[class*='option_select']").length != 0){
					
					$courses.empty();

					$courses.append($("<option  value=\"0\">请选择</option>"));
				}else{
					op.empty();

					op.append($("<option  value=\"0\">请选择</option>"));
					if(result.courseListAll.length != 0) {
						$.each(result.courseListAll, function() {
							$courses.append($("<option data-coursecolor='" + this.courseColer + "' data-courseid=" + this.courseId + ">" + this.courseName + "</option>"));
						});
					}
				}
				

				if(req.userList.length != 0) {
					$.each(req.userList, function() {
						ob.append($("<option data-stuorteaid=" + this.stuorteaId + ">" + this.userName + "</option>"));
					});
				}
				//				if(req.classList.length != 0) {
				//					$.each(req.classList, function() {
				//						if(oj.attr("style") == "display: none;") {
				//							this.classId = 0;
				//						}
				//						oj.append($("<option data-classid=" + this.classId + ">" + this.className + "</option>"));
				//					});
				//				}
				if(req.siteList.length != 0) {
					$.each(req.siteList, function() {
						ot.append($("<option data-siteid=" + this.siteId + ">" + this.siteName + "</option>"));
					});
				}
				if(req.directList.length != 0) {
					$.each(req.directList, function() {
						obj.append($("<option data-mainid=" + this.mainId + ">" + this.directName + "</option>"));
					});
				}

			},
			error: function(err) {
				window.location.href = "skipErrorPage";
			}
		});
	}
	//	/*显示弹出层*/
	//	function showModal() {
	//		$('.modal').show();
	//		$('.modal-bg').show();
	//	}

	/*隐藏弹出层*/
	//	function closeModal() {
	//		$('.modal').hide();
	//		$('.modal-bg').hide();
	//		window.location.href = "skipScheduleMana";
	//	}

	function getColor(value) {
		var result = new Array();
		if(value == 1) {
			result.push("color-pink");
			result.push("color-pink-inner");
		} else if(value == 2) {
			result.push("color-green");
			result.push("color-green-inner");
		} else if(value == 3) {
			result.push("color-blue");
			result.push("color-blue-inner");
		} else if(value == 4) {
			result.push("color-yellow");
			result.push("color-yellow-inner");
		} else if(value == 5) {
			result.push("color-purple");
			result.push("color-purple-inner");
		} else if(value == 6) {
			result.push("color-orange");
			result.push("color-orange-inner");
		} else if(value == 7) {
			result.push("color-red");
			result.push("color-red-inner");
		} else if(value == 8) {
			result.push("color-depblue");
			result.push("color-depblue-inner");
		} else if(value == 9) {
			result.push("color-depgreen");
			result.push("color-depgreen-inner");
		} else if(value == 10) {
			result.push("color-lightgreen");
			result.push("color-lightgreen-inner");
		}
		return result;
	};

})